package com.cloud.jvm.outofmemory;

import org.springframework.cglib.proxy.Enhancer;
import org.springframework.cglib.proxy.MethodInterceptor;

/**
 * @version v1.0
 * @author: TianXiang
 * @description:
 * @date: 2021/5/31
 */
public class Metaspace {

    static class OOMTest{}

    public static void main(String[] args) {
        while (true) {
            // cglib 动态代理 创建类
            Enhancer enhancer = new Enhancer();
            enhancer.setSuperclass(OOMTest.class);
            enhancer.setUseCache(false);
            enhancer.setCallback((MethodInterceptor) (o, method, objects, methodProxy) -> methodProxy.invokeSuper(o, objects));
            // 不断的在元空间内创建类信息
            enhancer.create();
        }
    }
    
}
